import http from './http';

export const imgUrlApi = {
  /**
   * 根据角色名称列表获取对应的图片URL
   * @param {Array<string>} characterNameList 角色名称列表
   * @returns {Promise<Map<string, string>>} 角色名称到图片URL的映射
   */
  async getCharacterURL(characterNameList) {
    if (!characterNameList || characterNameList.length === 0) {
      return new Map();
    }
    
    try {
      const response = await http.post('/image/url/character', characterNameList);
      if (response.data.code === 0) {
        console.log("获取角色图片URL成功:"+response.data.data);
        return new Map(Object.entries(response.data.data));
      } else {
        console.error('获取角色图片URL失败:', response.data.message);
        return new Map();
      }
    } catch (error) {
      console.error('获取角色图片URL请求失败:', error);
      return new Map();
    }
  },

  /**
   * 根据武器名称列表获取对应的图片URL
   * @param {Array<string>} weaponNameList 武器名称列表
   * @returns {Promise<Map<string, string>>} 武器名称到图片URL的映射
   */
  async getWeaponURL(weaponNameList) {
    if (!weaponNameList || weaponNameList.length === 0) {
      return new Map();
    }
    
    try {
      const response = await http.post('/image/url/weapon', weaponNameList);
      if (response.data.code === 0) {
        console.log("获取武器图片URL成功:"+response.data.data);
        return new Map(Object.entries(response.data.data));
      } else {
        console.error('获取武器图片URL失败:', response.data.message);
        return new Map();
      }
    } catch (error) {
      console.error('获取武器图片URL请求失败:', error);
      return new Map();
    }
  }
};
